public class MaxFrequencyElements {
  public int maxFrequencyElements(int[] nums) {
    int[] count = new int[101];
    int max = 0;
    for(int i=0;i<nums.length;i++){
      count[nums[i]]++;
      max = Math.max(max, count[nums[i]]);
    }
    int res = 0;
    for(int i=0;i<count.length;i++){
      if(count[i] == max)
        res += max;
    }
    return res;
  }
  public static void main(String[] args) {
    MaxFrequencyElements m = new MaxFrequencyElements();
    int[] nums = {1,2,2,3,1,4,2};
    System.out.println(m.maxFrequencyElements(nums));
  }
}
